<?php
/*
	
*/
defined('BY_JYA') or exit('Access Denied');
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$setting=$this->setting;
$return['banner']=$setting['hdps'];
$return['setting']=$setting;
if($_RQ['op']=='main'){
	$return['params']=array();
	$return['list']=array();
	set_html('title',$setting['title']?:'首页');
	$return['post']=array();
	$return['show_list']=array();
	$return['sharedata']=array(
		'title'=>$setting['share_title'],
		'desc'=>$setting['share_desc'],
		'link'=>custom_url('jy_mbaoming/index//fromuser='.$_SESSION['uid'].'&merchid='.$_SESSION['onemerchid'],true),
		'imgUrl'=>ATTACHMENT_URL.$setting['share_image'],
	);
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'status'=>'1');
	if($_RQ['keyword']){
		$params['title like']='%'.trim($_RQ['keyword']).'%';
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('jy_baoming_list',$params,array($pindex,$psize),$total,$fields,'','paixu desc,createtime desc');
	foreach($list as &$item){
		$num1=pdo_count('jy_baoming_order',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'activity_id'=>$item['id'],'status'=>1));
		$num2=pdo_count('jy_baoming_order',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'activity_id'=>$item['id'],'status'=>2));
		$num3=pdo_count('jy_baoming_order',array('merchid'=>$_SESSION['onemerchid'],'uniacid'=>$_SESSION['uniacid'],'activity_id'=>$item['id'],'status'=>4));
		$item['num']=$num1+$num2+$num3;
		if($item['mannum']-$item['num'] >= 0){
			$item['left']=$item['mannum']-$item['num'];
		}else{
			$item['left']=0;
		}
	}
	$return['list']=$list;
	exi($return);
}
